package com.lagou.ex.springboot.mybatisplus.base.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lagou.ex.springboot.mybatisplus.base.mapper.UserMapper;
import com.lagou.ex.springboot.mybatisplus.base.model.UserModel;
import com.lagou.ex.springboot.mybatisplus.base.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户操作
 */
@Service
@Slf4j
public class UserServiceImpl extends ServiceImpl<UserMapper, UserModel> implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<UserModel> queryByPhone(String phone) {
        log.info("/queryByPhone phone-{}", phone);
        return baseMapper.queryByPhone(phone);
    }

    @Override
    public boolean createUser(UserModel userModel) {
        userModel.setId(null);
        // TODO 密码加密存储
        boolean save = save(userModel);
        log.info("/createUser bean-{}", userModel);
        return save;
    }

}
